import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Form/index';
const appList = [
  {
    value: 0,
    label: '展示',
  },
  {
    value: 1,
    label: '隐藏',
  },
];
const typeList = [
  { label: '必选菜单', value: 0 },
  { label: '可选菜单', value: 1 },
  { label: '用户菜单', value: 2 },
];
export const menuColumns: BasicColumn[] = [
  {
    title: '代码',
    dataIndex: 'code',
    width: 130,
  },
  {
    title: '名称',
    dataIndex: 'name',
    width: 130,
  },
  {
    title: '菜单类型',
    dataIndex: 'type',
    customRender: ({ record }) => {
      return typeList[record.type].label;
    },
    width: 120,
  },
  {
    title: '选择',
    dataIndex: 'value',
    customRender: ({ record }) => {
      return record.value === 1 ? '需要' : '不需要';
    },
    width: 120,
  },
  {
    title: '说明',
    dataIndex: 'memo',
  },
  {
    title: '图像',
    dataIndex: 'image',
  },
  {
    title: '函数',
    dataIndex: 'method',
  },
  {
    title: 'App端按钮名称',
    dataIndex: 'appName',
    width: 150,
  },
  {
    title: 'App端按钮隐藏场景',
    dataIndex: 'appHiddenFlag',
    width: 150,
    ellipsis: true,
    customRender: ({ record }) => {
      return appList[record.appHiddenFlag]?.label;
    },
  },
];

export const menuSchemas: FormSchema[] = [
  {
    field: 'name',
    component: 'Input',
    label: `名称`,
    rules: [{ required: true }],
    colProps: {
      span: 12,
    },
  },
  {
    field: 'code',
    component: 'Input',
    label: `代码`,
    rules: [{ required: true }],
    colProps: {
      span: 12,
    },
  },
  {
    field: 'value',
    component: 'RadioGroup',
    label: '选择',
    colProps: {
      span: 12,
    },
    componentProps: {
      options: [
        {
          label: '需要',
          value: 1,
        },
        {
          label: '不需要',
          value: 0,
        },
      ],
    },
  },
  {
    field: 'type',
    label: '菜单类型',
    component: 'Select',
    required: true,
    componentProps: {
      options: typeList,
    },
    colProps: { span: 12 },
  },
  {
    field: 'memo',
    component: 'Input',
    label: `说明`,
    colProps: {
      span: 24,
    },
  },
  {
    field: 'image',
    component: 'Input',
    label: `图像`,
    colProps: {
      span: 24,
    },
  },
  {
    field: 'method',
    component: 'Input',
    label: `函数`,
    colProps: {
      span: 24,
    },
  },
  {
    field: 'appName',
    component: 'Input',
    label: `App端名称`,
    colProps: {
      span: 12,
    },
  },
  {
    field: 'appHiddenFlag',
    component: 'Select',
    label: `App端按钮显示`,
    componentProps: {
      options: appList,
    },
    colProps: {
      span: 12,
    },
  },
];
